<!DOCTYPE html>
<html>

<body>

<h2>Validation Example</h2>

<form  ng-app="myApp"  ng-controller="validateCtrl"
name="myForm" novalidate>

<p>用户名:<br>
  <input type="text" name="username" ng-model="username" required>
  
</p>

<p>邮箱:<br>
  <input type="password" name="password" ng-model="password" required>
  
</p>

<p>
  <button type="button" ng-click="submit()" class="btn btn-default col-sm-4" ng-disabled="myForm.username.$dirty && myForm.username.$invalid ||
  myForm.password.$dirty && myForm.password.$invalid" >登录</button>
</p>

</form>
<script type="text/javascript" src="lib/angular/angular.js"></script>
<script>
var app = angular.module('myApp', []);
app.controller('validateCtrl', function($scope) {
    $scope.username = 'af';
    $scope.password = 'a';
});
</script>

</body>
</html>